﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GlobalMgr : MonoBehaviour {
    //单例模式
    private GlobalMgr Instance;
    public GlobalMgr GetInstance() {
        if (Instance == null) {
            Instance = new GlobalMgr();
            return Instance;
        }
        return Instance;
    }
    void Awake() {
        GameObject obj = (GameObject)Instantiate(Resources.Load("Prefabs/Event"), Vector3.zero, Quaternion.identity);
        obj.transform.parent = GameObject.Find("Panel").transform;
        obj.transform.localScale = Vector3.one;


        //添加模块监听器
        gameObject.AddComponent<ModuleAListener>();
        gameObject.AddComponent<ModuleBListener>();
    }

    public static void EventMgr(string name, Dictionary<string, object> data = null)
    {
        UIEventArgs PanelArg = new UIEventArgs();
        PanelArg.Type = name;
        if (data != null)
            PanelArg.Data = data;
        EventManager.GetInstance.Raise(PanelArg);
    }
}
